﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Configuration;
using System.IO;
using System.Windows.Forms;

namespace Admin
{
    class Config
    {


        private string ip_manager = "";
        private int puerto_manager;
        private string path = "";

        public Config(string path)
        {
            this.path = path;
            CargarConfiguracion();
        }

        public string Ip_manager
        {
            get { return ip_manager; }
            set { ip_manager = value; }
        }

        public int Puerto_manager
        {
            get { return puerto_manager; }
            set { puerto_manager = value; }
        }

        private void CargarConfiguracion()
        {
           
            string path = ConfigurationManager.AppSettings["Path"];

            if (File.Exists(path))
            {
                XmlDocument xDoc = new XmlDocument();
                xDoc.Load(path);

                #region // Carga información de Manager
                XmlNode managerNode = xDoc.SelectSingleNode("//CONFIGURACION_ADMIN//MANAGER");
                Puerto_manager = int.Parse(managerNode.SelectSingleNode("PUERTO").InnerText);
                Ip_manager = managerNode.SelectSingleNode("IP").InnerText;
                #endregion
            }
            else
            {
                MessageBox.Show("Ruta de configuracion no encontrada..");
                Console.Read();
                Environment.Exit(0);
            }
        }

    }
}
